// 引入axios请求 
import { request, MockRequest } from "@/util/http";
export const requestCategoryList = () => {
  return request.get('/api/product/getBaseCategoryList')
}
// 获取banner数据
export const requestMockBanner = () => {
  return MockRequest.get('/banner')
}
// 获取floor数据
export const requestMockFloor = () => {
  return MockRequest.get('/floor')
}
// 搜索post请求
export const requestSearchList = (params) => {
  return request.post('/api/list', params)
}
// 根据传来的skuId搜索数据
export const requestSkuIdList = (skuId) => {
  return request.get(`/api/item/${skuId}`)
}
// 加入购物车的请求 对已有数据进行修改 接受两个参数 当前商品的id 和数量
export const requestAddOrUpdateCart = (skuId, skuNum) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}
// 购物车列表请求 拿到购物车当前对应的数据
export const requestShopCartList = () => {
  return request.get("/api/cart/cartList")
}
// 切换商品选中状态
export const requestChangeComState = ({ skuId, isChecked }) => {
  return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
}
// 修改所有商品的选中状态 skuIdList放请求体里
export const requestChangeAllComState = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList)
}
// 删除单个商品
export const requestDeleteCom = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`)
}
// 删除所有已选中商品
export const requestDeleteAllSelectCom = (skuIdList) => {
  return request.post(`/api/cart/batchDeleteCart`, {
    data: skuIdList
  })
}
// 注册页面
// 获取验证码的请求
export const requestGetCode = (phone) => {
  return request.get(`/api/user/passport/sendCode/${phone}`)
}
// 注册
export const requestSetAccount = (registerInfo) => {
  return request.post(`/api/user/passport/register`, registerInfo)
}
// 登录
export const requestLoginIn = (userInfo) => {
  return request.post('/api/user/passport/login', userInfo)
}
// 获取用户名
export const requestUserName = () => {
  return request.get('/api/user/passport/auth/getUserInfo')
}
// 退出登录
export const requestLoginOut = () => {
  return request.get('/api/user/passport/logout')
}
// 请求用户商品信息 
export const requestTradeInventory = () => {
  return request.get('/api/order/auth/trade')
}
// 获取用户地址
export const requestUserAddress = () => {
  return MockRequest.get('/address')
}
// 提交订单的请求
export const requestReferOrder = (tradeNo, userInfo) => {
  return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`, userInfo)
}
// 支付获取二维码的请求
export const requestPayDetail = (orderId) => {
  return request.get(`/api/payment/weixin/createNative/${orderId}`)
}
// 查看是否支付的状态
export const requestPayStatus = (orderId) => {
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}
// 获取我的订单列表
export const requestOrderList = ({ page, limit }) => {
  return request.get(`/api/order/auth/${page}/${limit}`)
}